import Channel from "./channel";

class AppUtil {
  static isWechatMp() {
    // #ifdef MP-WEIXIN
    return true
    // #endif
    return false
  }

  static isTouTiaoMp() {
    // #ifdef MP-TOUTIAO
    return true
    // #endif
    return false
  }

  static isH5() {
    // #ifdef H5
    return true
    // #endif
    return false
  }

  //判断是否微信
  static isWechatWeb() {
    let ua = window.navigator.userAgent.toLowerCase()
    return ua.includes('micromessenger')
  }

  static getThemeColor() {
    if (Channel.getAppInfo().color) {
      return Channel.getAppInfo().color
    }
    let product = Channel.getAppInfo().productId % 100
    if (product === 1) {
      // sdk
      return '#FF0036'
    } else if (product === 2) {
      // note se
      return '#12B7F5'
    } else if (product === 3) {
      // note
      return '#f59d00'
    } else if (product === 4) {
      // store old
      return '#FF0036'
    } else if (product === 5) {
      // store
      return '#FF0036'
    } else if (product === 6) {
      // mai ba
      return '#FF0036'
    } else if (product === 7) {
      // blue
      return '#12B7F5'
    } else {
      // 小程序|web
      return AppUtil.isTouTiaoMp() ? '#4044f3' : '#FF0036'
    }
  }
}

export default AppUtil